import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
import { SceneManager } from './SceneManager';
import DataManger from '../RunTime/DataManager';
import { ItemStatusEnum, ItemTypeEnum, SceneEnum } from '../Enum';
const { ccclass, property } = _decorator;

@ccclass('H2SceneManager')
export class H2SceneManager extends SceneManager {
    @property(Prefab)
    keyPF: Prefab = null

    @property(Node)
    keyPlaceHolder: Node = null

    type: SceneEnum = SceneEnum.H2
    

    rendor() {
        super.rendor()
        this.items.destroyAllChildren()
        const key = DataManger.Instance.items.find(i => i.type = ItemTypeEnum.Key)
        if (key && key.status === ItemStatusEnum.Scene) {
            const keynode = instantiate(this.keyPF)
            this.items.addChild(keynode)
            keynode.setPosition(this.keyPlaceHolder.position)
        }

    }
}


